package com.vf.admin.common.db.utils;

import java.util.HashMap;

/**
 * 查询的条件字段
 * @author anxiang
 *
 */

public class SelectColumn {
	public HashMap<String,Object> selectcolumn;
	public HashMap<String,Object> selectIncolumn;
	public HashMap<String,Object> selectIsNullcolumn;
	public HashMap<String,Object> paixucolumn;
	
	public static SelectColumn getInstance(){
		return new SelectColumn();
	}
	
	/**
	 * 添加需要查询出来的字段(精准条件)
	 * @return
	 */
	public HashMap<String,Object> add(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" = ", columnValue);
		return selectcolumn;
	}
	
	/**
	 * 添加需要查询出来的字段(精准条件)
	 * @return
	 */
	public HashMap<String,Object> addInWhere(String columnName,Object columnValue){
		if(selectIncolumn==null){
			selectIncolumn = new HashMap<String,Object>();
		}
		selectIncolumn.put(" "+columnName +" in (",columnValue);
		return selectIncolumn;
	}
	
	/**
	 * 添加需要查询出来的字段(精准条件)
	 * @return
	 */
	public HashMap<String,Object> addNot(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" != ", columnValue);
		return selectcolumn;
	}
	
	
	/**
	 * 添加需要查询数值为null的字段(精准条件)
	 * @return
	 */
	public HashMap<String,Object> addIsNull(String columnName){
		if(selectIsNullcolumn==null){
			selectIsNullcolumn = new HashMap<String,Object>();
		}
		selectIsNullcolumn.put(" "+columnName +" is null ", null);
		return selectIsNullcolumn;
	}
	
	/**
	 * 添加需要查询数值不为null的字段(精准条件)
	 * @return
	 */
	public HashMap<String,Object> addIsNotNull(String columnName){
		if(selectIsNullcolumn==null){
			selectIsNullcolumn = new HashMap<String,Object>();
		}
		selectIsNullcolumn.put(" "+columnName +" is not null ", null);
		return selectIsNullcolumn;
	}
	
	/**
	 * 添加需要查询出来的字段(前置模糊条件)
	 * @return
	 */
	public HashMap<String,Object> addLikeIndex(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" like ", " % "+columnValue);
		return selectcolumn;
	}
	/**
	 * 添加字段(前后置模糊条件)
	 * @return
	 */
	public HashMap<String,Object> addLikeIndexLast(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" like ", "%"+columnValue+"%");
		return selectcolumn;
	}
	/**
	 * 添加字段(后置模糊条件)
	 * @return
	 */
	public HashMap<String,Object> addLikeLast(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" like ", columnValue+" % ");
		return selectcolumn;
	}
	
	/**
	 * 添加字段(小于条件)
	 * @return
	 */
	public HashMap<String,Object> addXiaoYu(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" < ", columnValue);
		return selectcolumn;
	}
	
	/**
	 * 添加字段(小于等于条件)
	 * @return
	 */
	public HashMap<String,Object> addXiaoYuDengYu(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" <= ", columnValue);
		return selectcolumn;
	}
	
	/**
	 * 添加字段(大于条件)
	 * @return
	 */
	public HashMap<String,Object> addDaYu(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" > ", columnValue+"");
		return selectcolumn;
	}
	
	/**
	 * 添加字段(大于等于条件)
	 * @return
	 */
	public HashMap<String,Object> addDaYuDengYu(String columnName,Object columnValue){
		if(selectcolumn==null){
			selectcolumn = new HashMap<String,Object>();
		}
		selectcolumn.put(" "+columnName +" >= ", columnValue);
		return selectcolumn;
	}
	
	
	/**
	 * 添加字段(正排序条件)
	 * @return
	 */
	public HashMap<String,Object> addZhengPaiXu(String columnName){
		if(paixucolumn==null){
			paixucolumn = new HashMap<String,Object>();
		}
		paixucolumn.put(" order by "+columnName+" asc ", "");
		return paixucolumn;
	}
	
	
	/**
	 * 添加字段(倒排序条件)
	 * @return
	 */
	public HashMap<String,Object> addDaoPaiXu(String columnName){
		if(paixucolumn==null){
			paixucolumn = new HashMap<String,Object>();
		}
		paixucolumn.put(" order by "+columnName+" desc ", "");
		return paixucolumn;
	}
	
	
	public HashMap<String, Object> getSelectcolumn() {
		return selectcolumn;
	}
	public void setSelectcolumn(HashMap<String, Object> selectcolumn) {
		this.selectcolumn = selectcolumn;
	}

	public HashMap<String, Object> getPaixucolumn() {
		return paixucolumn;
	}

	public void setPaixucolumn(HashMap<String, Object> paixucolumn) {
		this.paixucolumn = paixucolumn;
	}

	public HashMap<String, Object> getSelectIsNullcolumn() {
		return selectIsNullcolumn;
	}

	public void setSelectIsNullcolumn(HashMap<String, Object> selectIsNullcolumn) {
		this.selectIsNullcolumn = selectIsNullcolumn;
	}

	public HashMap<String, Object> getSelectIncolumn() {
		return selectIncolumn;
	}

	public void setSelectIncolumn(HashMap<String, Object> selectIncolumn) {
		this.selectIncolumn = selectIncolumn;
	}
}
